package blazingbubble.network.game.strategy;

import java.util.Collection;

import blazingbubble.game.Game;
import moltencore.network.protocol.PlayerScoreUpdate;
import org.apache.log4j.Logger;
import spark.network.protocol.Acknowledgement;
import spark.network.protocol.Response;
import spark.network.strategy.IProtocolHandleStrategy;
import spark.network.protocol.Base;
import spark.utility.OutWrapper;

public class PlayerScoreUpdateStrategy implements IProtocolHandleStrategy<PlayerScoreUpdate> {
	private Logger logger = Logger.getLogger(PlayerJoinedGameStrategy.class);

	private Game game;

	public PlayerScoreUpdateStrategy(Game game) {
		this.game = game;
	}

	@Override
	public void handle(PlayerScoreUpdate packet, OutWrapper<Response> acknowledgement, Collection<Base> additionalData) {
		game.getField(packet.getFieldId()).setScore(packet.getNewScore());
		acknowledgement.value = new Acknowledgement(packet);
	}
}
